from celery import Celery
import time
broker_redis='redis://127.0.0.1:6379/1'
backend_redis='redis://127.0.0.1:6379/2'
app=Celery('test',broker=broker_redis,backend=backend_redis)

@app.task
def x1(x,y):
    return x+y

@app.task
def x2(x,y):
    return x-y
@app.task
def send_email(name):
    print(f'向{name}发送邮件...')
    time.sleep(4)
    print(f'向{name}发送邮件完成...')
    return 'ok'